"""
工厂模式
"""


class Person:
    pass

class Student(Person):
    pass

class Teacher(Person):
    pass

class Worker(Person):
    pass

class PersonFactory:

    def get_person(self,t:str):
        # type_dict={'w':Worker.__init__,'s':Student.__init__,'t':Teacher.__init__}
        # t= type_dict[type]
        # print(t)
        # return t()
        # 此处使用反射语法更方便，但目前没有找到比较方便的形式
        if t=='w':
            return Worker()
        elif t=='t':
            return Teacher()
        else:
            return Student()


print(type("Worker",(),{})())

pf=PersonFactory()
wor=pf.get_person('w')
print(wor)
tea=pf.get_person('t')
print(tea)
stu=pf.get_person('s')
print(stu)
# z=pf.get_person('z')
# print(z)